<?php

namespace app\xs_test\controller\api;

use xsframe\base\ApiBaseController;

class React extends ApiBaseController
{
    // loop 循环
    public function loop()
    {
        require_once $this->moduleIaRoot . '/vendor/autoload.php';

        $http = new React\Http\HttpServer(function (Psr\Http\Message\ServerRequestInterface $request) {
            return React\Http\Message\Response::plaintext(
                "Hello World!\n"
            );
        });

        $socket = new React\Socket\SocketServer('127.0.0.1:8080');
        $http->listen($socket);


        echo "Listening on http://localhost:8080";
    }
}
